<?php
//if (isset($_SESSION['username'])) {
include_once 'header.php';
require_once("../conn.php");
require_once("../change_page.php");
require_once 'market.action.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" charset= "utf-8 "/>
        <title>乐知家园</title>
        <script language="javascript">
            function getRealData(){
                location.href = "marketUpload.php?method=real&menu=uploadtime";
            }
            function getModifyData(){
                location.href = "marketUpload.php?method=modify&menu=uploadtime";
            }            
        </script>
        <style type="text/css">
            <!--
            body,td,th {
                font-family: 微软雅黑;
                font-size: 14px;
                color: #000000;
            }

            .STYLE1 {color: #FFFFFF}
            -->
        </style></head>
    <?php
    $method = "";
    if (isset($_GET['method']) && $_GET['method'] == "real") {
        $method = "real";
    } else if (isset($_GET['method']) && $_GET['method'] == "modify") {
        $method = "modify";
    }
    if ($method == "real") {
        $data = getRealUpload();
    } else {
        $data = getNewestProductByUploadTime();
    }
    ?>
    <body>
        <br/>
        <form action="save.action.php?module=uploadtime" method="post">
        <table width="80%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#9999FF">
            <tr align="center">
                <td align="left">
                    &nbsp;<input type="button" value="获得真实数据" <?php if ($method == "real") { echo "disabled=\"disabled\""; } ?> onclick="getRealData()"/>
                    &nbsp;<input type="button" value="显示修改后数据" <?php if ($method == "modify") { echo "disabled=\"disabled\""; } ?> onclick="getModifyData()"/>
                    &nbsp;<input type="submit" value="保存" onclick="save()"/></td>                
            </tr>
        </table>
        <br/>
        <table width="80%" border="0" align="center" cellpadding="1" cellspacing="1">
            <tr align="center">
                <td bgcolor="#666666" width="5%"><span class="STYLE1">序号</span></td>
                <td bgcolor="#666666" width="15%" align="left">&nbsp;<span class="STYLE1">编号</span></td>
                <td bgcolor="#666666" width="50%" align="left">&nbsp;<span class="STYLE1">名称</span></td>
                <td bgcolor="#666666" width="20%" align="left">&nbsp;<span class="STYLE1">上传时间</span></td>                
            </tr>
            <?php
            $num = 0;
            if ($data != false && count($data) > 0) {
                foreach ($data as $row) {
                    if (!isset($row['num'])) {
                        $row['num'] = $num + 1;
                    }
                    ?>
                    <tr>
                        <td bgcolor="#FFFFFF">&nbsp;<?php echo++$num; ?></td>
                        <td bgcolor="#FFFFFF">&nbsp;<input type="text" name="code[]" value="<?php echo $row['code']; ?>" style="width:100px;" /></td>
                        <td bgcolor="#FFFFFF">&nbsp;<input type="text" name="name[]" disabled="disabled" value="<?php echo $row['name']; ?>" style="width:400px;" /></td>
                        <td bgcolor="#FFFFFF">&nbsp;<input type="text" name="uploadTime[]" disabled="disabled" value="<?php echo $row['uploadTime']; ?>" style="width:150px;" /><input type="hidden" name="num[]" value="<?php echo $num; ?>" />&nbsp;</td>
                    </tr>
                    <?php
                }
            }
            if ($num < 20) {
                for ($i = $num; $i < 20; $i++) {
                    ?>
                    <tr>
                        <td bgcolor="#FFFFFF">&nbsp;<?php echo++$num; ?></td>
                        <td bgcolor="#FFFFFF">&nbsp;<input type="text" name="code[]" value="" style="width:100px;" /></td>
                        <td bgcolor="#FFFFFF">&nbsp;<input type="text" name="name[]" disabled="disabled" value="" style="width:400px;" /></td>
                        <td bgcolor="#FFFFFF">&nbsp;<input type="text" name="uploadTime[]" disabled="disabled" value="" style="width:150px;" /><input type="hidden" name="num[]" value="<?php echo $num; ?>" />&nbsp;</td>
                    </tr>
                    <?php
                }
            }
            ?>
        </table>
        </form>
    </body>
</html>
<?php
include_once '../footer.php';
?>